package com.example.ry.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.ry.bean.Menu;
import com.example.ry.bean.ParamsData;
import com.example.ry.bean.Role;
import com.example.ry.bean.User;
import com.example.ry.service.UserService;

@RestController
public class TestController {

	@Resource(name = "userService")
	private UserService userService;
	
	@RequestMapping("test")
	public String test() {
		return "test method";
	}
	
	@RequestMapping("getUserList")
	public String getUserList() {
		ParamsData pd=new ParamsData();
		pd.put("username", "szj");
		pd.put("userid", 1);
		
		User user=userService.selectUserByUsername(pd);
		System.out.println(user.getId()+" "+user.getUsername());
		
		User userRole = userService.selectUserRoleByUsername(pd);
		List<Role> roleList=userRole.getRoles();
		for (Role role : roleList) {
			System.out.println(role.getRolename());
		}
		
		List<Menu> menuList=userService.selectMenuByUsername(pd);
		for (Menu menu : menuList) {
			System.out.println(menu.getPermission());
		}
		
		return "";
	}
	
}
